package com.ziyia.a4_1_3;

import androidx.appcompat.app.AppCompatActivity;

import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import java.io.Serializable;

public class MainActivity2 extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);

        Intent intent = getIntent();
        Bundle bundle = intent.getExtras();

        User user = (User) bundle.getSerializable("user");

        new AlertDialog.Builder(this)
                .setTitle("接收到数据")
                .setMessage(user.toString())
                .create()
                .show();
    }

    public void finish(View view) {
        finish();
    }

    public void setResult(View view) {
        Intent intent = getIntent();
        intent.putExtra("username", "数据数据");
        setResult(200, intent);
        finish();
    }
}